/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package com.unwiredgrain.modeling.sscm.impl;

import com.unwiredgrain.modeling.sscm.BasicModule;
import com.unwiredgrain.modeling.sscm.Classifier;
import com.unwiredgrain.modeling.sscm.Socket;
import com.unwiredgrain.modeling.sscm.CompositeModule;
import com.unwiredgrain.modeling.sscm.Export;
import com.unwiredgrain.modeling.sscm.Interface;
import com.unwiredgrain.modeling.sscm.InterfaceTemplateInstantiation;
import com.unwiredgrain.modeling.sscm.Port;
import com.unwiredgrain.modeling.sscm.PortDirection;
import com.unwiredgrain.modeling.sscm.InnerConnector;
import com.unwiredgrain.modeling.sscm.IntTemplateInstantiation;
import com.unwiredgrain.modeling.sscm.IntTemplateParameter;
import com.unwiredgrain.modeling.sscm.IntegerValue;
import com.unwiredgrain.modeling.sscm.NamedElement;
import com.unwiredgrain.modeling.sscm.Operation;
import com.unwiredgrain.modeling.sscm.OperationDirection;
import com.unwiredgrain.modeling.sscm.OperationParameter;
import com.unwiredgrain.modeling.sscm.OuterConnector;
import com.unwiredgrain.modeling.sscm.Protocol;
import com.unwiredgrain.modeling.sscm.ProtocolTemplateInstantiation;
import com.unwiredgrain.modeling.sscm.SSCMFactory;
import com.unwiredgrain.modeling.sscm.SSCMPackage;
import com.unwiredgrain.modeling.sscm.TypeModifier;
import com.unwiredgrain.modeling.sscm.TypeTemplateInstantiation;
import com.unwiredgrain.modeling.sscm.TypeTemplateParameter;
import com.unwiredgrain.modeling.sscm.Wire;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.impl.EFactoryImpl;

import org.eclipse.emf.ecore.plugin.EcorePlugin;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class SSCMFactoryImpl extends EFactoryImpl implements SSCMFactory {
	/**
	 * Creates the default factory implementation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static SSCMFactory init() {
		try {
			SSCMFactory theSSCMFactory = (SSCMFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.unwiredgrain.com/simple-static-component-model/1.0"); 
			if (theSSCMFactory != null) {
				return theSSCMFactory;
			}
		}
		catch (Exception exception) {
			EcorePlugin.INSTANCE.log(exception);
		}
		return new SSCMFactoryImpl();
	}

	/**
	 * Creates an instance of the factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SSCMFactoryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EObject create(EClass eClass) {
		switch (eClass.getClassifierID()) {
			case SSCMPackage.BASIC_MODULE: return createBasicModule();
			case SSCMPackage.CLASSIFIER: return createClassifier();
			case SSCMPackage.SOCKET: return createSocket();
			case SSCMPackage.COMPOSITE_MODULE: return createCompositeModule();
			case SSCMPackage.INTERFACE: return createInterface();
			case SSCMPackage.INTERFACE_TEMPLATE_INSTANTIATION: return createInterfaceTemplateInstantiation();
			case SSCMPackage.PORT: return createPort();
			case SSCMPackage.INTEGER_VALUE: return createIntegerValue();
			case SSCMPackage.INT_TEMPLATE_INSTANTIATION: return createIntTemplateInstantiation();
			case SSCMPackage.INT_TEMPLATE_PARAMETER: return createIntTemplateParameter();
			case SSCMPackage.NAMED_ELEMENT: return createNamedElement();
			case SSCMPackage.OPERATION: return createOperation();
			case SSCMPackage.OPERATION_PARAMETER: return createOperationParameter();
			case SSCMPackage.PACKAGE: return createPackage();
			case SSCMPackage.PROTOCOL: return createProtocol();
			case SSCMPackage.PROTOCOL_TEMPLATE_INSTANTIATION: return createProtocolTemplateInstantiation();
			case SSCMPackage.TYPE_TEMPLATE_INSTANTIATION: return createTypeTemplateInstantiation();
			case SSCMPackage.TYPE_TEMPLATE_PARAMETER: return createTypeTemplateParameter();
			case SSCMPackage.WIRE: return createWire();
			case SSCMPackage.EXPORT: return createExport();
			case SSCMPackage.INNER_CONNECTOR: return createInnerConnector();
			case SSCMPackage.OUTER_CONNECTOR: return createOuterConnector();
			default:
				throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object createFromString(EDataType eDataType, String initialValue) {
		switch (eDataType.getClassifierID()) {
			case SSCMPackage.PORT_DIRECTION:
				return createPortDirectionFromString(eDataType, initialValue);
			case SSCMPackage.OPERATION_DIRECTION:
				return createOperationDirectionFromString(eDataType, initialValue);
			case SSCMPackage.TYPE_MODIFIER:
				return createTypeModifierFromString(eDataType, initialValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String convertToString(EDataType eDataType, Object instanceValue) {
		switch (eDataType.getClassifierID()) {
			case SSCMPackage.PORT_DIRECTION:
				return convertPortDirectionToString(eDataType, instanceValue);
			case SSCMPackage.OPERATION_DIRECTION:
				return convertOperationDirectionToString(eDataType, instanceValue);
			case SSCMPackage.TYPE_MODIFIER:
				return convertTypeModifierToString(eDataType, instanceValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BasicModule createBasicModule() {
		BasicModuleImpl basicModule = new BasicModuleImpl();
		return basicModule;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Classifier createClassifier() {
		ClassifierImpl classifier = new ClassifierImpl();
		return classifier;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Socket createSocket() {
		SocketImpl socket = new SocketImpl();
		return socket;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CompositeModule createCompositeModule() {
		CompositeModuleImpl compositeModule = new CompositeModuleImpl();
		return compositeModule;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Interface createInterface() {
		InterfaceImpl interface_ = new InterfaceImpl();
		return interface_;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public InterfaceTemplateInstantiation createInterfaceTemplateInstantiation() {
		InterfaceTemplateInstantiationImpl interfaceTemplateInstantiation = new InterfaceTemplateInstantiationImpl();
		return interfaceTemplateInstantiation;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Port createPort() {
		PortImpl port = new PortImpl();
		return port;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IntegerValue createIntegerValue() {
		IntegerValueImpl integerValue = new IntegerValueImpl();
		return integerValue;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IntTemplateInstantiation createIntTemplateInstantiation() {
		IntTemplateInstantiationImpl intTemplateInstantiation = new IntTemplateInstantiationImpl();
		return intTemplateInstantiation;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IntTemplateParameter createIntTemplateParameter() {
		IntTemplateParameterImpl intTemplateParameter = new IntTemplateParameterImpl();
		return intTemplateParameter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NamedElement createNamedElement() {
		NamedElementImpl namedElement = new NamedElementImpl();
		return namedElement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Operation createOperation() {
		OperationImpl operation = new OperationImpl();
		return operation;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OperationParameter createOperationParameter() {
		OperationParameterImpl operationParameter = new OperationParameterImpl();
		return operationParameter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public com.unwiredgrain.modeling.sscm.Package createPackage() {
		PackageImpl package_ = new PackageImpl();
		return package_;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Protocol createProtocol() {
		ProtocolImpl protocol = new ProtocolImpl();
		return protocol;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ProtocolTemplateInstantiation createProtocolTemplateInstantiation() {
		ProtocolTemplateInstantiationImpl protocolTemplateInstantiation = new ProtocolTemplateInstantiationImpl();
		return protocolTemplateInstantiation;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TypeTemplateInstantiation createTypeTemplateInstantiation() {
		TypeTemplateInstantiationImpl typeTemplateInstantiation = new TypeTemplateInstantiationImpl();
		return typeTemplateInstantiation;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TypeTemplateParameter createTypeTemplateParameter() {
		TypeTemplateParameterImpl typeTemplateParameter = new TypeTemplateParameterImpl();
		return typeTemplateParameter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Wire createWire() {
		WireImpl wire = new WireImpl();
		return wire;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Export createExport() {
		ExportImpl export = new ExportImpl();
		return export;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public InnerConnector createInnerConnector() {
		InnerConnectorImpl innerConnector = new InnerConnectorImpl();
		return innerConnector;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OuterConnector createOuterConnector() {
		OuterConnectorImpl outerConnector = new OuterConnectorImpl();
		return outerConnector;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PortDirection createPortDirectionFromString(EDataType eDataType, String initialValue) {
		PortDirection result = PortDirection.get(initialValue);
		if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertPortDirectionToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OperationDirection createOperationDirectionFromString(EDataType eDataType, String initialValue) {
		OperationDirection result = OperationDirection.get(initialValue);
		if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertOperationDirectionToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TypeModifier createTypeModifierFromString(EDataType eDataType, String initialValue) {
		TypeModifier result = TypeModifier.get(initialValue);
		if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertTypeModifierToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SSCMPackage getSSCMPackage() {
		return (SSCMPackage)getEPackage();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @deprecated
	 * @generated
	 */
	@Deprecated
	public static SSCMPackage getPackage() {
		return SSCMPackage.eINSTANCE;
	}

} //SSCMFactoryImpl
